//
//  LandmarkDetail.swift
//  SwiftUi
//
//  Created by xm on 21/08/2025.
//

import SwiftUI



struct LandmarkDetail: View {
    var landmark: Landmark
    @State var zoomed = false
    
    var body: some View {
        ZStack(alignment: .bottomTrailing){
            Image(landmark.imageName).resizable()
                .aspectRatio(contentMode: zoomed ? .fill : .fit )
                .frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity)
                .navigationBarTitle(landmark.name, displayMode: .inline)
                .onTapGesture { // 点击
                    withAnimation {
                        zoomed.toggle()
                        
                    }
                }
            
            if !zoomed {
                Text(landmark.name).font(.largeTitle).foregroundColor(.secondary).padding()
                    .transition(.move(edge: .trailing))
            }
        }
    }
}


#Preview {
    Group {
        NavigationStack{
            LandmarkDetail(landmark: landmarks[0])
//            LandmarkDetail(landmark: landmarks[1])
        }
    }
   
    
}
